//
//  BaseNavigationController.m
//  PFBrainTwister
//
//  Created by perfayMini on 2018/4/4.
//  Copyright © 2018年 perfayMini. All rights reserved.
//

#import "BaseNavigationController.h"
#import "UIBarButtonItem+BTExtension.h"
@interface BaseNavigationController ()<UINavigationControllerDelegate, UIGestureRecognizerDelegate>

@end

@implementation BaseNavigationController


- (void)viewDidLoad {
    [super viewDidLoad];
    self.delegate = self;
//    id target = self.interactivePopGestureRecognizer.delegate;
//    UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:target action:@selector(handleNavigationTransition:)];
//    [self.view addGestureRecognizer:pan];
//    self.interactivePopGestureRecognizer.enabled = NO;
}



#pragma mark - UINavigationControllerDelegate
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
//    // 判断如果是需要隐藏导航控制器的类，则隐藏
//    BOOL isHideNav = ([viewController isKindOfClass:[ViewController class]] ||
//                      [viewController isKindOfClass:[WYTargetVC class]]);
//
//    [self setNavigationBarHidden:isHideNav animated:YES];
}


+ (void)initialize{
    UINavigationBar * bar = [UINavigationBar appearance];
    bar.barTintColor = [UIColor qmui_colorWithHexString:@"a58eee"];
    bar.titleTextAttributes = @{NSForegroundColorAttributeName:[UIColor whiteColor],NSFontAttributeName:[UIFont systemFontOfSize:18]};
}


- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
    
    if(self.childViewControllers.count > 0){
        viewController.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithImage:[UIImage imageNamed:@"com_bt_ttab_return_normal"] selectImage:[UIImage imageNamed:@"com_bt_ttab_return_pressed"] addTarget:self action:@selector(backBtnClicked)];
    }
    [super pushViewController:viewController animated:animated];
    
}

- (void)backBtnClicked
{
    if (self.presentingViewController) {
        [self dismissViewControllerAnimated:YES completion:nil];
    }else{
        [self popViewControllerAnimated:YES];
    }
}
@end
